Repository navigation
DEV-1266: Android HIL queueStress, to reproduce the lock-order deadlock - #136
Merged
JongChern merged 3 commits intoOct 23, 2026
Merged
Conversation
The driver guards its instruction queue with two locks, the device and the queue. Up to 0.11.10_beta its IO thread took them queue first when it fetched the next instruction, and every call that queues one takes them device first, so the two could deadlock and every later call hung. On Android it hung 5 of 12 inStream runs on driver 0.11.7_beta, but inStream needs SD logging and catches it only by chance. queueStress makes the window wide on purpose, as the Java HIL's scenario of the same name does. With the unit connected and idle, timers on, four threads queue battery and status reads in tight loops for 60 s, keeping the queue under 8. Idle, because while streaming Android writes these reads straight out, unqueued, and they never take the queue's lock. It needs no SD card, so it also runs on a docked or charging unit. It fails when a read doesn't return within 10 s or no read returns for 10 s, with every thread's stack in the events; when a read throws; or when the queue doesn't drain within 15 s. The runner runs it by default and the README lists it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 23, 2026
Up to driver 0.11.10_beta, a configuration written straight after stopStreaming() could lose its first chunk, the one holding the sampling rate: operationPrepare() cleared the instruction list while the STOP was still in flight, and the stop's reply then retired the next instruction in its place. The unit kept its old rate. The Java HIL's samplingRates found it on a Shimmer3 and a Shimmer3R. Android configures through the same driver code over both transports, and had no scenario for it. samplingRates, as in the Java and shimmer-logandstream HILs, writes 51.2, 256 and 512 Hz in turn and streams 5 s at each, then writes the unit's own rate back; every configure but the first comes straight after a stop. Unlike the Java HIL's configure, the Android one can finish on the manager's SUCCESS without looking at the rate, so the scenario checks that the rate read back is the one written. No SD card is needed. The runner runs it by default and the README lists it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…pling_rates DEV-1306: Android HIL samplingRates, configuring straight after a stop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DEV-1266. A new Android HIL scenario,
queueStress, that reproduces the driver's lock-order deadlock on demand, so #135's driver bump can be shown to fix it on Android. Stacked on #134; merge #128 and #134 first.Why a new scenario
The driver guards its instruction queue with two locks, the device and the queue. Up to 0.11.10_beta its IO thread took them queue first when fetching the next instruction, while every call that queues an instruction takes them device first. The two could deadlock, and every later call hung. On Android this hung 5 of 12
inStreamruns on driver 0.11.7_beta, butinStreamneeds SD logging and only catches it by chance.queueStresswidens the window on purpose, as the Java HIL's scenario of the same name does. With the unit connected and idle, timers on, four threads queue battery and status reads in tight loops for 60 s, keeping the queue under 8. It runs idle because, while streaming, Android writes these reads straight out, unqueued, so they never take the queue's lock. It needs no SD card, so it runs on a docked or charging unit too.It fails when a read doesn't return within 10 s, no read returns for 10 s, or the queue doesn't drain within 15 s after the reads stop; each of these puts every thread's stack in the events. It also fails when a read throws. The runner runs it by default and the README lists it.
Tested on the bench
Phone M2101K6G (Android 11). s3-3e36 is a Shimmer3, LogAndStream v1.1.7, over Classic; s3r-2f31 is a Shimmer3R, v1.1.22, over BLE. The link CRC was 1 byte. The library build was this branch merged with #122, #132, #133, #134 and #135.
Every deadlock's thread dump is DEV-1266's signature:
getInstruction()→getListofInstructions(), holding the queue and waiting for the device;writeInstruction(), holding the device and waiting for the queue;🤖 Generated with Claude Code